<?php

require __DIR__.'/../../../vendor/autoload.php';

use Gateway\app\non_mainland_cn3\Id_name_imageRequest;
use Gateway\ESGateway;
use Gateway\JSONUtil;
use Gateway\Log;

$appCode = "d2808c1338ce01f3e3efdb486f9effb9";
$algo = "3";
$key = "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEhdQdw6uTGz+X4e+/eGpu4dcKrfrjQAe0tTQyn6TuKBobcsUsESkx9jcCeG4cpuxmN8jNeDAZsbTujNLD/aYl2g==";
$esGateway = new ESGateway($appCode, $algo, $key);

$id_name_imageRequest = new Id_name_imageRequest();
$id_name_imageRequest->nation = "CHN";
$id_name_imageRequest->idType = "1";
$id_name_imageRequest->name = "黄小橘";
$id_name_imageRequest->idNO = "751114215478";
$path = 'resources'.DIRECTORY_SEPARATOR.'cn_idcard.jpeg';//拼接路径
$imageData =file_get_contents($path);
$base64String  = base64_encode($imageData);
$id_name_imageRequest->personImg = $base64String;

$gatewayResponse = $esGateway->sendToGateWay(Id_name_imageRequest::$act,$id_name_imageRequest->toJsonStr());
Log::DEBUG("服务器返回数据：".$gatewayResponse->toJsonStr());
if ($gatewayResponse->bizContent != null) {
    Log::DEBUG("业务数据为：".$gatewayResponse->bizContent);
    $rsp = JSONUtil::fromJsonStr($gatewayResponse->bizContent);
}
